package common

import (
	"crypto/md5"
	"encoding/hex"
)

func MD5Encode(data string) string {
	h := md5.New()
	h.Write([]byte(data))
	return hex.EncodeToString(h.Sum(nil))
}

func MakePassword(plainwd, salt string) string {
	return MD5Encode(plainwd + salt)
}
func ValidPassword(plainwd, salt, password string) bool {
	md := MD5Encode(plainwd + salt)
	return md == password
}
